Kinetis SDK API Reference Manual  1.0.0-beta
Freescale Semiconductor, Inc.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
fsl_mcg_hal.h File Reference
#include <stdint.h>
#include <stdbool.h>
#include <assert.h>
#include "fsl_device_registers.h"
#include "fsl_mcg_features.h"

Enumerations

enum  _mcg_constant {
  kMcgConstant1 = (1u),
  kMcgConstant5 = (5u),
  kMcgConstant640 = (640u),
  kMcgConstant1280 = (1280u),
  kMcgConstant1920 = (1920u),
  kMcgConstant2560 = (2560u),
  kMcgConstant732 = (732u),
  kMcgConstant1464 = (1464u),
  kMcgConstant2197 = (2197u),
  kMcgConstant2929 = (2929u),
  kMcgConstantHex20 = (0x20u),
  kMcgConstantHex40 = (0x40u),
  kMcgConstantHex60 = (0x60u),
  kMcgConstantHex80 = (0x80u),
  kMcgConstantHexA0 = (0xA0u),
  kMcgConstantHexC0 = (0xC0u),
  kMcgConstantHexE0 = (0xE0u)
}
 MCG constant definitions.
 
enum  mcg_clock_select_t {
  kMcgClockSelectOut,
  kMcgClockSelectIn,
  kMcgClockSelectExt,
  kMcgClockSelectReserved
}
 MCG clock source select.
 
enum  mcg_iref_clock_source_t {
  kMcgIrefClockSourceExt,
  kMcgIrefClockSourceSlow
}
 MCG internal reference clock source select.
 
enum  mcg_freq_range_select_t {
  kMcgFreqRangeSelectLow,
  kMcgFreqRangeSelectHigh,
  kMcgFreqRangeSelectVeryHigh,
  kMcgFreqRangeSelectVeryHigh1
}
 MCG frequency range select.
 
enum  mcg_hgo_select_t {
  kMcgHgoSelectLow,
  kMcgHgoSelectHigh
}
 MCG high gain oscillator select.
 
enum  mcg_eref_clock_select_t {
  kMcgErefClockSelectExt,
  kMcgErefClockSelectOsc
}
 MCG high gain oscillator select.
 
enum  mcg_lp_select_t {
  kMcgLpSelectNormal,
  kMcgLpSelectLowPower
}
 MCG low power select.
 
enum  mcg_iref_clock_select_t {
  kMcgIrefClockSelectSlow,
  kMcgIrefClockSelectFast
}
 MCG internal reference clock select.
 
enum  mcg_dmx32_select_t {
  kMcgDmx32Default,
  kMcgDmx32Fine
}
 MCG DCO Maximum Frequency with 32.768 kHz Reference.
 
enum  mcg_dco_range_select_t {
  kMcgDcoRangeSelectLow,
  kMcgDcoRangeSelectMid,
  kMcgDcoRangeSelectMidHigh,
  kMcgDcoRangeSelectHigh
}
 MCG DCO range select.
 
enum  mcg_pll_eref_clock_select_t {
  kMcgPllErefClockSelectOsc0,
  kMcgPllErefClockSelectOsc1
}
 MCG PLL external reference clock select.
 
enum  mcg_pll_select_t {
  kMcgPllSelectFll,
  kMcgPllSelectPllcs
}
 MCG PLL select.
 
enum  mcg_lols_status_t {
  kMcgLolsNotLostLock,
  kMcgLolsLostLock
}
 MCG loss of lock status.
 
enum  mcg_lock_status_t {
  kMcgLockUnlocked,
  kMcgLockLocked
}
 MCG lock status.
 
enum  mcg_pllst_status_t {
  kMcgPllstFll,
  kMcgPllstPllcs
}
 MCG clock status.
 
enum  mcg_irefst_status_t {
  kMcgIrefstExt,
  kMcgIrefstInt
}
 MCG iref status.
 
enum  mcg_clkst_status_t {
  kMcgClkstFll,
  kMcgClkstIref,
  kMcgClkstEref,
  kMcgClkstPll
}
 MCG clock mode status.
 
enum  mcg_ircst_status_t {
  kMcgIrcstSlow,
  kMcgIrcstFast
}
 MCG ircst status.
 
enum  mcg_atmf_status_t {
  kMcgAtmfNormal,
  kMcgAtmfFail
}
 MCG auto trim fail status.
 
enum  mcg_locs0_status_t {
  kMcgLocs0NotOccured,
  kMcgLocs0Occured
}
 MCG loss of clock status.
 
enum  mcg_atms_select_t {
  kMcgAtmsSelect32k,
  kMcgAtmsSelect4m
}
 MCG Automatic Trim Machine Select.
 
enum  mcg_oscsel_select_t {
  kMcgOscselOsc,
  kMcgOscselRtc,
  kMcgOscselIrc
}
 MCG OSC Clock Select.
 
enum  mcg_locs1_status_t {
  kMcgLocs1NotOccured,
  kMcgLocs1Occured
}
 MCG loss of clock status.
 
enum  mcg_pllcs_select_t {
  kMcgPllcsSelectPll0,
  kMcgPllcsSelectPll1
}
 MCG PLLCS select.
 
enum  mcg_locs2_status_t {
  kMcgLocs2NotOccured,
  kMcgLocs2Occured
}
 MCG loss of clock status.
 

Functions

MCG out clock access API
uint32_t clock_hal_get_fllclk (void)
 Gets the current MCG FLL clock. More...
 
uint32_t clock_hal_get_pll0clk (void)
 Gets the current MCG PLL/PLL0 clock. More...
 
uint32_t clock_hal_get_irclk (void)
 Gets the current MCG IR clock. More...
 
uint32_t clock_hal_get_outclk (void)
 Gets the current MCG out clock. More...
 
MCG control register access API
static void clock_set_clks (mcg_clock_select_t select)
 Sets the Clock Source Select. More...
 
static mcg_clock_select_t clock_get_clks (void)
 Gets the Clock Source Select. More...
 
static void clock_set_frdiv (uint8_t setting)
 Sets the FLL External Reference Divider. More...
 
static uint8_t clock_get_frdiv (void)
 Gets the FLL External Reference Divider. More...
 
static void clock_set_irefs (mcg_iref_clock_source_t select)
 Sets the Internal Reference Select. More...
 
static mcg_iref_clock_source_t clock_get_irefs (void)
 Gets the Internal Reference Select. More...
 
static void clock_set_clks_frdiv_irefs (mcg_clock_select_t clks, uint8_t frdiv, mcg_iref_clock_source_t irefs)
 Sets the CLKS, FRDIV and IREFS at the same time. More...
 
static void clock_set_irclken (bool enable)
 Sets the Enable Internal Reference Clock setting. More...
 
static bool clock_get_irclken (void)
 Gets the enable Internal Reference Clock setting. More...
 
static void clock_set_irefsten (bool enable)
 Sets the Internal Reference Clock Stop Enable setting. More...
 
static bool clock_get_irefsten (void)
 Gets the Enable Internal Reference Clock setting. More...
 
static void clock_set_locre0 (bool enable)
 Sets the Loss of Clock Reset Enable setting. More...
 
static bool clock_get_locre0 (void)
 Gets the Loss of Clock Reset Enable setting. More...
 
static void clock_set_range0 (mcg_freq_range_select_t select)
 Sets the Frequency Range Select. More...
 
static mcg_freq_range_select_t clock_get_range0 (void)
 Gets the Frequency Range Select. More...
 
static void clock_set_hgo0 (mcg_hgo_select_t select)
 Sets the High Gain Oscillator Select. More...
 
static mcg_hgo_select_t clock_get_hgo0 (void)
 Gets the High Gain Oscillator Select. More...
 
static void clock_set_erefs0 (mcg_eref_clock_select_t select)
 Sets the External Reference Select. More...
 
static mcg_eref_clock_select_t clock_get_erefs0 (void)
 Gets the External Reference Select. More...
 
static void clock_set_lp (mcg_lp_select_t select)
 Sets the Low Power Select. More...
 
static mcg_lp_select_t clock_get_lp (void)
 Gets the Low Power Select. More...
 
static void clock_set_ircs (mcg_iref_clock_select_t select)
 Sets the Internal Reference Clock Select. More...
 
static mcg_iref_clock_select_t clock_get_ircs (void)
 Gets the Internal Reference Clock Select. More...
 
static void clock_set_sctrim (uint8_t setting)
 Sets the Slow Internal Reference Clock Trim Setting. More...
 
static uint8_t clock_get_sctrim (void)
 Gets the Slow Internal Reference Clock Trim Setting. More...
 
static void clock_set_dmx32 (mcg_dmx32_select_t setting)
 Sets the DCO Maximum Frequency with 32.768 kHz Reference. More...
 
static mcg_dmx32_select_t clock_get_dmx32 (void)
 Gets the DCO Maximum Frequency with the 32.768 kHz Reference Setting. More...
 
static void clock_set_drst_drs (mcg_dco_range_select_t setting)
 Sets the DCO Range Select. More...
 
static mcg_dco_range_select_t clock_get_drst_drs (void)
 Gets the DCO Range Select Setting. More...
 
static void clock_set_fctrim (uint8_t setting)
 Sets the Fast Internal Reference Clock Trim Setting. More...
 
static uint8_t clock_get_fctrim (void)
 Gets the Fast Internal Reference Clock Trim Setting. More...
 
static void clock_set_scftrim (uint8_t setting)
 Sets the Slow Internal Reference Clock Fine Trim Setting. More...
 
static uint8_t clock_get_scftrim (void)
 Gets the Slow Internal Reference Clock Fine Trim Setting. More...
 
static void clock_set_pllclken0 (bool enable)
 Sets the PLL Clock Enable Setting. More...
 
static bool clock_get_pllclken0 (void)
 Gets the PLL Clock Enable Setting. More...
 
static void clock_set_pllsten0 (bool enable)
 Sets the PLL0 Stop Enable Setting. More...
 
static bool clock_get_pllsten0 (void)
 Gets the PLL0 Stop Enable Setting. More...
 
static void clock_set_prdiv0 (uint8_t setting)
 Sets the PLL0 External Reference Divider Setting. More...
 
static uint8_t clock_get_prdiv0 (void)
 Gets the PLL0 External Reference Divider Setting. More...
 
static void clock_set_lolie0 (bool enable)
 Sets the Loss of Lock Interrupt Enable Setting. More...
 
static bool clock_get_lolie0 (void)
 Gets the Loss of the Lock Interrupt Enable Setting. More...
 
static void clock_set_plls (mcg_pll_select_t setting)
 Sets the PLL Select Setting. More...
 
static mcg_pll_select_t clock_get_plls (void)
 Gets the PLL Select Setting. More...
 
static void clock_set_cme0 (bool enable)
 Sets the Clock Monitor Enable Setting. More...
 
static bool clock_get_cme0 (void)
 Gets the Clock Monitor Enable Setting. More...
 
static void clock_set_vdiv0 (uint8_t setting)
 Sets the VCO0 Divider Setting. More...
 
static uint8_t clock_get_vdiv0 (void)
 Gets the VCO0 Divider Setting. More...
 
static mcg_lols_status_t clock_get_lols0 (void)
 Gets the Loss of the Lock Status. More...
 
static mcg_lock_status_t clock_get_lock0 (void)
 Gets the Lock Status. More...
 
static mcg_pllst_status_t clock_get_pllst (void)
 Gets the PLL Select Status. More...
 
static mcg_irefst_status_t clock_get_irefst (void)
 Gets the Internal Reference Status. More...
 
static mcg_clkst_status_t clock_get_clkst (void)
 Gets the Clock Mode Status. More...
 
static uint8_t clock_get_oscinit0 (void)
 Gets the OSC Initialization Status. More...
 
static mcg_ircst_status_t clock_get_ircst (void)
 Gets the Internal Reference Clock Status. More...
 
static mcg_atmf_status_t clock_get_atmf (void)
 Gets the Automatic Trim machine Fail Flag. More...
 
static void clock_set_atmf (void)
 Sets the Automatic Trim machine Fail Flag. More...
 
static mcg_locs0_status_t clock_get_locs0 (void)
 Gets the OSC0 Loss of Clock Status. More...
 
static void clock_set_atme (bool enable)
 Sets the Automatic Trim Machine Enable Setting. More...
 
static bool clock_get_atme (void)
 Gets the Automatic Trim Machine Enable Setting. More...
 
static void clock_set_atms (mcg_atms_select_t setting)
 Sets the Automatic Trim Machine Select Setting. More...
 
static mcg_atms_select_t clock_get_atms (void)
 Gets the Automatic Trim Machine Select Setting. More...
 
static void clock_set_fltprsrv (bool enable)
 Sets the FLL Filter Preserve Enable Setting. More...
 
static bool clock_get_fltprsrv (void)
 Gets the FLL Filter Preserve Enable Setting. More...
 
static void clock_set_fcrdiv (uint8_t setting)
 Sets the Fast Clock Internal Reference Divider Setting. More...
 
static uint8_t clock_get_fcrdiv (void)
 Gets the Fast Clock Internal Reference Divider Setting. More...
 
static void clock_set_atcvh (uint8_t setting)
 Sets the ATM Compare Value High Setting. More...
 
static uint8_t clock_get_atcvh (void)
 Gets the ATM Compare Value High Setting. More...
 
static void clock_set_atcvl (uint8_t setting)
 Sets the ATM Compare Value Low Setting. More...
 
static uint8_t clock_get_atcvl (void)
 Gets the ATM Compare Value Low Setting. More...